<?php
include '../conn.php';

$cateNos = '01|(^02|04|05|06|08|09)\/newsInfo|02|03|04|05|06|07|08|09';
$hashReg = '/^#?\/?('.$cateNos.'){0,1}\/?/i';
$match_result = preg_match($hashReg, $_POST['cateNo'], $matches);
$cateNo = isset($matches[1]) ? $matches[1] : '01';
$query = "select * from tb_category where categoryNo='{$cateNo}'";
$query_result = mysqli_query($link,$query);
while ($row = mysqli_fetch_array($query_result)) {
    $cateId = $row['id'];

}

switch (strval($cateNo)) {
    case '01':
	case '03':
	case '05':
	case '06':
	case '08':
	    if (isset($_POST['id']) && isset($_POST['type'])){
            //查询二级栏目,并且id为。。
            $query = "select * from tb_category where level = 1 and id =".$_POST['id'];
            $category_res = mysqli_query($link, $query);
            while ($row = mysqli_fetch_array($category_res)) {
                if ($row['type'] == 'url') {
                    include "./subPages/dynamic.php";
                    exit();
                }
            }
        }
        echo include "./subPages/department.php";
        break;
    case '02':
    case '04':
    case '09':
        echo include "./subPages/dynamic.php";
        break; 
    case '02/newsInfo':
    case '04/newsInfo':
    case '05/newsInfo':
    case '06/newsInfo':
    case '08/newsInfo':
    case '09/newsInfo':
        echo include "./subPages/newsInfo.php";
        break;
    case '07':
        echo include "./subPages/teacherStyle.html";
        break;
    default:
        echo include "./subPages/department.php";
        break;
}
